<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
</head>
<body>
    <h1>商品分类</h1>
    <ul>
        {% for category in categories %}
            <li>
                <a href="{% url 'category_detail' category.id %}">{{ category.name }}</a>
                {% if category.subcategories.all %}
                    <ul>
                        {% for subcategory in category.subcategories.all %}
                            <li><a href="{% url 'category_detail' subcategory.id %}">{{ subcategory.name }}</a></li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </li>
        {% endfor %}
    </ul>

    <h1>商品列表</h1>
    <ul>
        {% for product in products %}
            <li>
                <a href="{% url 'product_detail' product.id %}">{{ product.name }}</a>
                <p>价格: ¥{{ product.price }}</p>
                <p>库存: {{ product.stock }}</p>
            </li>
        {% endfor %}
    </ul>
</body>
</html>